Pin Description
Applications
/* Name : main.c
* Purpose : Source code for LCD Interfacing with ARM LPC1248.
* Author : Gemicates
* Date : 2018-19-01
* Website : www.gemicates.org
* Revision : None
*/
#include<lpc21xx.h> // header file for LPC21XX series
#define LCD (0xff<<16)
#define RS (1<<13) // register select pin
#define RW (1<<14) // read write pin
#define EN (1<<15) // enable pin
// Function declarations
void delay_fv(unsigned int x,int y);
void lcd_display(unsigned int x);
void cmd(unsigned char m);
void lcd_ini();
int main()
{
PINSEL0=0X00000000; // select PORT0 as GPIO mode
IO0DIR=0XFFFFFFFF; // make PORT0 pin as Output mode
lcd_ini();
while(1) // Repeat(loop) forever
{
lcd_ini();
lcd_display(' ');
lcd_display('W');
delay_fv(1000,400);
lcd_display('E');
delay_fv(1000,400);
lcd_display('L');
delay_fv(1000,400);
lcd_display('C');
delay_fv(1000,400);
lcd_display('O');
delay_fv(1000,400);
lcd_display('M');
delay_fv(1000,400);
lcd_display('E');
delay_fv(1000,400);
lcd_display(' ');
delay_fv(1000,400);
lcd_display('T');
delay_fv(1000,400);
lcd_display('O');
delay_fv(1000,400);
cmd(0xc0); // bring cursor to second ROW
lcd_display(' ');
delay_fv(1000,400);
lcd_display(' ');
delay_fv(1000,400);
lcd_display(' ');
delay_fv(1000,400);
lcd_display('G');
delay_fv(1000,400);
lcd_display('E');
delay_fv(1000,400);
lcd_display('M');
delay_fv(1000,400);
lcd_display('I');
delay_fv(1000,400);
lcd_display('C');
delay_fv(1000,400);
lcd_display('A');
delay_fv(1000,400);
lcd_display('T');
delay_fv(1000,400);
lcd_display('E');
delay_fv(1000,400);
lcd_display('S');
delay_fv(1000,400);
}
}
void delay_fv(unsigned int x,int y) // Time delay function in milli seconds
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<y;j++);
}
void lcd_display(unsigned int x) // Function to send data to LCD
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(x<<16);
IO0SET|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,10);
IO0CLR|=EN;
delay_fv(10,10);
}
void cmd(unsigned char m) // Function to send command to LCD
{
IO0CLR|=(RS|RW|EN|LCD);
IO0SET|=(m<<16);
IO0CLR|=RS;
IO0CLR|=RW;
IO0SET|=EN;
delay_fv(100,100);
IO0CLR|=EN;
delay_fv(100,10);
}
void lcd_ini() // Funtion to Initialize LCD
{
cmd(0X38); // for using 8-bit 2 row mode and 5x7 Dots of LCD
cmd(0X0e); // turn display ON for cursor blinking
cmd(0X06); // display ON
cmd(0X01); // clear screen
cmd(0X80); // clear screen
}